#***************************************************************************************
# Copyright (c) 2014-2022 Zihao Yu, Nanjing University
#
# NEMU is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#          http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#
# See the Mulan PSL v2 for more details.
#**************************************************************************************/

# Sanity check
NEMU_PATH = $(abspath ./)

# Include variables and rules generated by menuconfig
-include $(NEMU_PATH)/include/config/auto.conf
-include $(NEMU_PATH)/include/config/auto.conf.cmd

# Extract variabls from menuconfig
GUEST_ISA ?= riscv32
ENGINE ?= interpreter
NAME    = $(GUEST_ISA)-nemu-$(ENGINE)

INC_PATH += $(NEMU_PATH)/src/isa/riscv32/include
SHARE = 1

SRCS = $(shell find ./src -name "*.c")

# Extract compiler and options from menuconfig
CC = gcc
CFLAGS_BUILD += -O2
CFLAGS  += $(CFLAGS_BUILD) -D__GUEST_ISA__=$(GUEST_ISA)
LDFLAGS += $(CFLAGS_BUILD)

FIXDEP_PATH  := $(NEMU_PATH)/tools/fixdep
FIXDEP := $(FIXDEP_PATH)/build/fixdep

# Include rules to build NEMU
include $(NEMU_PATH)/scripts/native.mk
